#!user/bin/env python3
# -- coding: utf-8 --
# @Createtime：2023/8/29 9:58
# @Updatetime：9:58
# @Author：Test008
# @File：7-各种事件
# @Description：
import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('file:///C:/Users/EDY/PycharmProjects/Appium_test/static/html/testAlert.html')
driver.implicitly_wait(3)
driver.maximize_window()
# 1》触发对话框
driver.find_element(By.CSS_SELECTOR, '#bu1').click()
# 2》获取对话框
alert = driver.switch_to.alert
time.sleep(2)
# 3》点击确认
alert.accept()

# 1》点击显示确认框
driver.find_element(By.CSS_SELECTOR, '#bu2').click()
# 2》点击取消
alert = driver.switch_to.alert
time.sleep(2)
alert.dismiss()
# 3》再次点击显示确认框
driver.find_element(By.CSS_SELECTOR, '#bu2').click()
time.sleep(2)
alert = driver.switch_to.alert
# 4》点击确认
alert.accept()

# 1》点击显示提示框
# 2》输入内容：水泊梁山非好汉，天王未必盖地虎
# 3》点击取消
# 4》再次点击显示提示框
# 5》输入内容：水泊梁山非好汉，天王未必盖地虎
# 6》点击确认
driver.find_element(By.CSS_SELECTOR, '#bu3').click()
time.sleep(2)
alert = driver.switch_to.alert
alert.send_keys('水泊梁山非好汉，天王未必盖地虎')
time.sleep(1)
alert.dismiss()
driver.find_element(By.CSS_SELECTOR, '#bu3').click()
time.sleep(2)
alert = driver.switch_to.alert
alert.send_keys('水泊梁山非好汉，天王未必盖地虎')
alert.accept()








time.sleep(3)
driver.quit()
